The HealthWorkoutEvent
class provides an interface for accessing workout-related events in Apple Health data. Each event represents a specific moment or action within a workout session, such as when the workout is paused, resumed, or marked with a lap or milestone.
HealthWorkoutEventType
This enum defines the various types of workout events.
Value | Name | Description |
---|---|---|
1 |
pause |
Indicates that the workout was paused manually. |
2 |
resume |
Indicates that the workout was resumed after a pause. |
3 |
lap |
Marks a lap during the workout, useful for sports like running or swimming. |
4 |
marker |
A generic marker placed by the system or user for reference. |
5 |
motionPaused |
Indicates that the workout was automatically paused due to no movement. |
6 |
motionResumed |
Workout automatically resumed after detecting motion. |
7 |
segment |
Marks the start of a new workout segment, e.g., during interval training. |
8 |
pauseOrResumeRequest |
A system-generated request to pause or resume, not a guaranteed action. |
HealthWorkoutEvent
Property | Type | Description |
---|---|---|
type |
HealthWorkoutEventType |
The specific event type (e.g., pause, lap, motionPaused). |
dateInterval |
HealthDateInterval |
The time interval during which this event occurred. |
metadata |
Record<string, any> | null |
Optional metadata describing additional information about the event. |
Note:
HealthDateInterval
containsstart
,end
, andduration
(in seconds).
HealthWorkout
instance, which includes these events as an array.